package com.credit.jumu.playcard.base;

import android.app.ProgressDialog;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;

import com.credit.jumu.playcard.utils.StatusBarCompat;

/**
 * Created by Administrator on 2017/10/23/023.
 */

public class BaseActivity extends AppCompatActivity {

	private ProgressDialog dialog;
	ImageView backView;

	@Override
	protected void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		//设置状态栏文字颜色及图标为深色
//		getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
//		StatusBarCompat.compat(this, Color.parseColor("#000000"));
	}

	public void backClick(int r, final AppCompatActivity activity){
		backView = (ImageView) findViewById(r);
		backView.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				activity.finish();
			}
		});
	}
	public void showLoading() {
		if (dialog != null && dialog.isShowing()) return;
		dialog = new ProgressDialog(this);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.setCanceledOnTouchOutside(false);
		dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
		dialog.setMessage("请求网络中...");
		dialog.show();
	}
	public void dismissLoading() {
		if (dialog != null && dialog.isShowing()) {
			dialog.dismiss();
		}
	}

}
